/**
 * @Title:Role.java
 * @Package:com.xpjhs.role
 * @Description:TODO
 * @author:luckyboyguo@126.com
 * @date:2015年1月16日{time}
 * @version:v1.0
 */
package com.xpjhs.role.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.xpjhs.permission.model.Permission;
import com.xpjhs.user.model.User;

/**
 * @ClassName:Role
 * @Description:{todo}
 * @author luckyboyguo@126.com
 * @date:2015年1月16日上午10:46:37
 */
@Entity
@Table(name="xpjhs_role")
public class Role implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long id; 
	private List<Permission> permissions; //权限
	private String roleName;//角色名称
	private String title;//中文名称
	private List<User> users;//用户
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public long getId() {
		return id;
	}
	@ManyToMany
	@JoinTable(name="xpjhs_role_permission",joinColumns={@JoinColumn(name="role_id")},inverseJoinColumns={@JoinColumn(name="permission_id")})
	public List<Permission> getPermissions() {
		return permissions;
	}
	public String getRoleName() {
		return roleName;
	}
	public String getTitle() {
		return title;
	}
	@ManyToMany(mappedBy="roles",cascade=CascadeType.MERGE)
	public List<User> getUsers() {
		return users;
	}
	public void setId(long id) {
		this.id = id;
	}
	public void setPermissions(List<Permission> permissions) {
		this.permissions = permissions;
	}
	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public void setUsers(List<User> users) {
		this.users = users;
	}
}
